﻿using Business;
using Business.Solr;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Client {
    public static class Program {
        public static void Main() {
            var solrClient = new SolrClient(Config.GetValue("SolrUpdateUrl"), Config.GetValue("SolrSelectUrl"));
            var emailBox = new EmailBox(Config.GetValue("hostname"), int.Parse(Config.GetValue("port")), false, Config.GetValue("username"), Config.GetValue("password"));
            var messages = emailBox.GetMessages(header => new NewMessageFilter(Config.GetValue("from"), Config.GetValue("subject"), solrClient).IsNewResume(header));
            foreach (var message in messages) {
                var parser = new ResumeParser();
                var resume = parser.Parse(message);
                resume.Trim();

                solrClient.Save(resume);
                Console.WriteLine(resume);
            }
            Console.ReadLine();
        }
    }
}
